/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import com.sesame.service.ContactService;

/**
 * @author voidman
 * 
 */

public class DeleteFriendController extends AbstractController {

    private ContactService contactService;

    public void setContactService(ContactService contactService) {
        this.contactService = contactService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse reponse) throws Exception {

        Integer user1Id = (Integer) request.getSession().getAttribute("userId");
        Integer user2Id = Integer.parseInt(request.getParameter("user2Id"));
        contactService.deleteFriend(user1Id, user2Id);

        return new ModelAndView("redirect:userHome.html?userId=" + user2Id);

    }

}